import {request} from "./index"
/** 获取地址列表
 * 
 * @param {string} memberId
 * @param {number} page
 * @param {number} size
 */
const getAddress = (memberId, page, size, token) => {
  return request.get("v1/app/member/address", {
    page,
    size,
    memberId
  }, {
    Authorization: token
  })
}
/** 新增地址
 * 
 * @param {object} data
 * @param {string} data.consigneeAddressPath
 * @param {boolean} data.isDefault 是否为默认地址
 * @param {string} data.mobile
 * @param {string} data.name
 */
const addAddress = (data, token) => {
  return request.postFrom("v1/app/member/address", data, {
    "Authorization": token,
    "content-type": "application/x-www-form-urlencoded"
  })
}
/** 修改地址
 * 
 * @param {object} data 
 * @param {string} data.consigneeAddressPath
 * @param {string} data.detail
 * @param {boolean} data.isDefault
 * @param {string} data.mobile
 * @param {string} data.name
 */
const editAddress = (id, data, token) => {
  return request.put(`v1/app/member/address/${id}`, data, {
    "Authorization": token,
    "content-type": "application/x-www-form-urlencoded"
  })
}
/** 删除地址
 * 
 * @param {string} id 
 */
const deleteAddress = (id, token) => {
  return request.delete(`v1/app/member/address/delById/${id}`, {}, {
    "Authorization": token,
    "content-type": "application/x-www-form-urlencoded"
  })
}
/** 根据ID获取地址
 * 
 * @param {string} id 
 */
const getUserAddress = (id) => {
  return request.delete(`v1/app/member/address/get/${id}`, data)
}
export {
  getAddress,
  addAddress,
  editAddress,
  deleteAddress,
  getUserAddress
}